from rest_framework import serializers
from persons.models import Person


class PersonLstSerl(serializers.ModelSerializer):
    STATUS_CHOISE = (
        (0, "新创建"),
        (1, "申请中"),
        (2, "待入场"),
        (3, "已入场"),
        (4, "已出场"),
    )
    status_text = serializers.ChoiceField(
        choices=STATUS_CHOISE, source="get_status_display"
    )
    updated = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    class Meta:
        model = Person
        fields = (
            "uuid",
            "dept",
            "name",
            "phone",
            "status",
            "status_text",
            "updated",
        )


class PersonBriefSerl(serializers.ModelSerializer):
    STATUS_CHOISE = (
        (0, "新创建"),
        (1, "申请中"),
        (2, "待入场"),
        (3, "已入场"),
        (4, "已出场"),
    )
    status_text = serializers.ChoiceField(
        choices=STATUS_CHOISE, source="get_status_display"
    )

    class Meta:
        model = Person
        fields = (
            "uuid",
            "dept",
            "name",
            "phone",
            "status",
            "status_text",
        )


class PersonDetSerl(serializers.ModelSerializer):
    STATUS_CHOISE = (
        (0, "新创建"),
        (1, "申请中"),
        (2, "待入场"),
        (3, "已入场"),
        (4, "已出场"),
    )
    status_text = serializers.ChoiceField(
        choices=STATUS_CHOISE, source="get_status_display"
    )
    updated = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S")

    class Meta:
        model = Person
        exclude = ("created",)
